Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generator: fix off-by-one in mavlink_get_msg_entry #343

Merged
merged 1 commit into from
Sep 17, 2019

Conversation

julianoes
Copy link
Contributor

When parsing and discovering a big enough (and possibly invalid) msgid, we ended up accessing the last + 1 element of mavlink_message_crcs.

This was found by fuzz testing against mavlink_parse_char with address sanitizer enabled.

@magicrub
Copy link
Contributor

Who's doing the fuzz testing? It has been talked about for a while, didn't know anyone was actually doing it yet. Great find!

@julianoes
Copy link
Contributor Author

@magicrub I started doing some fuzz testing here: https://github.com/Auterion/mavlink-fuzz-testing
I don't know if that's the right place for such a test though. I'd be happy to integrate it in existing MAVLink testing infrastructure but I haven't looked into that.

When parsing and discovering a big enough (and possibly invalid) msgid,
we ended up accessing the last + 1 element of mavlink_message_crcs.

This was found by fuzz testing against mavlink_parse_char with address
sanitizer enabled.
@julianoes julianoes force-pushed the fix-msg-entry-off-by-one branch from 0806b4b to 34308c1 Compare August 19, 2019 13:38
Copy link
Member

@OXINARF OXINARF left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change looks good to me (high should be the index of the last array position to be checked, not the size).

I have to say though that I don't really comprehend the algorithm used here, it seems to mix two versions:

  • the standard binary search where you check and return (in the loop) if the middle is the right one, and
  • the alternative where after the loop you check if the chosen index is the right one

@OXINARF OXINARF requested a review from tridge August 19, 2019 14:29
@julianoes
Copy link
Contributor Author

Do you need more changes from me or can this get in?

@julianoes
Copy link
Contributor Author

Sorry for the bump. Could this go in?

@julianoes
Copy link
Contributor Author

Bump 🥺.

@tridge
Copy link
Contributor

tridge commented Sep 17, 2019

good, find, thanks!

@tridge tridge merged commit 2b190eb into ArduPilot:master Sep 17, 2019
@julianoes julianoes deleted the fix-msg-entry-off-by-one branch September 17, 2019 11:27
@julianoes
Copy link
Contributor Author

Thanks @tridge!

julianoes added a commit to mavlink/mavlink that referenced this pull request Sep 17, 2019
hamishwillee pushed a commit to mavlink/mavlink that referenced this pull request Sep 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants